package com.nx.currnet;

import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

@Slf4j
public class MyReenTrantLock {

   static Lock customLock=new ReentrantLock(true);

    public static void main(String[] args) {

        Thread  t1=new Thread(()->{
            try {
                customLock.lock();
                log.debug("t1");
                log.debug("t1");
                log.debug("t1");
                log.debug("t1");
                log.debug("t1");
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                customLock.unlock();
            }

        },"t1");


        Thread t2 =new Thread(()->{
            try {
                customLock.lock();
                log.debug("t2");
                log.debug("t2");
                log.debug("t2");
                log.debug("t2");
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                customLock.unlock();
            }
        },"t2");

        t1.start();
        t2.start();
    }


}
